﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;

namespace GUI
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }

        private void frmMain_Load(object sender, EventArgs e) {
            //this.BackgroundImage = Image.FromStream(this.GetType().Assembly.GetManifestResourceStream("background.jpg"));
        }

        private void thêmSáchMớiToolStripMenuItem_Click(object sender, EventArgs e) {
            foreach (Form item in this.MdiChildren) {
                if (item is frmQuanLySach) {
                    item.Focus();
                    return;
                }
            }

            frmQuanLySach quanLySach = new frmQuanLySach();
            quanLySach.MdiParent = this;
            quanLySach.Show();
        }

        private void phiếuNhậpSáchToolStripMenuItem_Click(object sender, EventArgs e) {
            foreach (Form item in this.MdiChildren) {
                if (item is frmPhieuNhapSach) {
                    item.Focus();
                    return;
                }
            }
            frmPhieuNhapSach phieuNhap = new frmPhieuNhapSach();
            phieuNhap.MdiParent = this;
            phieuNhap.Show();
        }

        private void hóaĐơnBánSáchToolStripMenuItem_Click(object sender, EventArgs e) {
            foreach (Form item in this.MdiChildren) {
                if (item is frmHoaDonBanSach) {
                    item.Focus();
                    return;
                }
            }
            frmHoaDonBanSach hoaDon = new frmHoaDonBanSach();
            hoaDon.MdiParent = this;
            hoaDon.Show();
        }

        private void lậpPhiếuThuTiềnToolStripMenuItem_Click(object sender, EventArgs e) {
            foreach (Form item in this.MdiChildren) {
                if (item is frmPhieuThuTien) {
                    item.Focus();
                    return;
                }
            }

            frmPhieuThuTien phieuThu = new frmPhieuThuTien();
            phieuThu.MdiParent = this;
            phieuThu.Show();
        }

        private void thayĐổiQuyĐịnhToolStripMenuItem_Click(object sender, EventArgs e) {
            foreach (Form item in this.MdiChildren) {
                if (item is frmThamSo) {
                    item.Focus();
                    return;
                }
            }

            frmThamSo thamSo = new frmThamSo();
            thamSo.MdiParent = this;
            thamSo.Show();
        }

        private void thoatToolStripMenuItem_Click(object sender, EventArgs e) {
            if (MessageBox.Show("Bạn có chắc muốn thoát?", "???", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                Close();
        }

        private void thêmKháchHàngMớiToolStripMenuItem_Click(object sender, EventArgs e) {
            foreach (Form item in this.MdiChildren) {
                if (item is frmQuanLyKhachHang) {
                    item.Focus();
                    return;
                }
            }

            frmQuanLyKhachHang quanLyKhachHang = new frmQuanLyKhachHang();
            quanLyKhachHang.MdiParent = this;
            quanLyKhachHang.Show();
        }

        private void traCứuSáchToolStripMenuItem_Click(object sender, EventArgs e) {
            foreach (Form item in this.MdiChildren) {
                if (item is frmTraCuu) {
                    item.Focus();
                    return;
                }
            }

            frmTraCuu traCuu = new frmTraCuu();
            traCuu.MdiParent = this;
            traCuu.Show();
        }

        private void báoCáoTồnToolStripMenuItem_Click(object sender, EventArgs e) {
            foreach (Form item in this.MdiChildren) {
                if (item is frmBaoCaoTon) {
                    item.Focus();
                    return;
                }
            }

            frmBaoCaoTon baoCaoTon = new frmBaoCaoTon();
            baoCaoTon.MdiParent = this;
            baoCaoTon.Show();
        }

        private void báoCáoCôngNợToolStripMenuItem_Click(object sender, EventArgs e) {
            foreach (Form item in this.MdiChildren) {
                if (item is frmBaoCaoCongNo) {
                    item.Focus();
                    return;
                }
            }

            frmBaoCaoCongNo baoCaoCongNo = new frmBaoCaoCongNo();
            baoCaoCongNo.MdiParent = this;
            baoCaoCongNo.Show();
        }

        private void trợGiúpToolStripMenuItem1_Click(object sender, EventArgs e) {
            Process c = new Process();
            c.StartInfo.FileName = "HELP.chm";
            c.Start();
        }

        private void vềChươngTrìnhToolStripMenuItem_Click(object sender, EventArgs e) {
            string str = "chương trình quản lý nhà sách \n SV thực hiện: \n - Trần Ngọc Huy Tưởng \n - Nguyễn Thị Nương";
            MessageBox.Show(str);
        }
    }
}
